package net.riaspace.zendAmfDs
{
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.utils.ObjectUtil;
	
	internal class Responder implements IResponder
	{
		private var _resultHandler:Function;
		
		private var _faultHandler:Function;

		public function Responder(resultHandler:Function = null, faultHandler:Function = null)
		{
			_resultHandler = resultHandler;
			_faultHandler = faultHandler;
		}
						
		public function result(data:Object):void
		{
			if (_resultHandler != null)
			{
				_resultHandler.call(null, data);
			}
		}
		
		public function fault(info:Object):void
		{
			if (_faultHandler != null)
			{	
				_faultHandler.call(null, info);
			}
			else
			{
				trace("RemoteObject call returned error, no faultHandler was specified!");
				trace(ObjectUtil.toString(info));
			}
		}
	}	
}